using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using VSSAHT.Transfer;
using VSS_AHT.DataAccess;

namespace VSSAHT.DataAccess
{
	public partial class ScaleTicketMapper
	{
		#region ToEntity

		public static ScaleTicket ToEntity(ScaleTicket entity, ScaleTicketDTO businessobject)
		{
			if (businessobject == null)
			{
				return null;
			}
			entity.Active = businessobject.Active;
			entity.ActualWeight = businessobject.ActualWeight;
			entity.CustomerCode = businessobject.CustomerCode;
			entity.CustomerName = businessobject.CustomerName;
            entity.Description = businessobject.Description;
			entity.FirstWeight = businessobject.FirstWeight;
			entity.InHour = businessobject.InHour;
			entity.ItemName = businessobject.ItemName;
			entity.ItemNumber = businessobject.ItemNumber;
			entity.ItemUnit = businessobject.ItemUnit;
			entity.ItemUnit2 = businessobject.ItemUnit2;
			entity.LocationCode = businessobject.LocationCode;
            entity.LocationName = businessobject.LocationName;
			entity.ModifiedBy = businessobject.ModifiedBy;
			entity.ModifiedDate = businessobject.ModifiedDate;
			entity.OutHour = businessobject.OutHour;
			entity.Quantity1 = businessobject.Quantity1;
			entity.Quantity2 = businessobject.Quantity2;
            entity.RequireCode = businessobject.RequireCode;
            entity.RequireName = businessobject.RequireName;
            entity.RequireLimit = businessobject.RequireLimit;
			entity.ScaleTicketCode = businessobject.ScaleTicketCode;
			entity.ScaleTicketID = businessobject.ScaleTicketID;
			entity.SecondWeight = businessobject.SecondWeight;
			entity.VehicleID = businessobject.VehicleID;
            entity.PercentReduce = businessobject.PercentReduce;
            entity.KgReduce = businessobject.KgReduce;
            entity.Rate = businessobject.Rate;
            entity.RowVersion = VersionConverter.ToBinary(businessobject.RowVersion);
			return entity;
		}

		#endregion

		#region ToBusinessObject

		public static ScaleTicketDTO ToBusinessObject(ScaleTicket entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ScaleTicketDTO
			{
				Active = entity.Active,
				ActualWeight = entity.ActualWeight,
				CustomerCode = entity.CustomerCode,
				CustomerName = entity.CustomerName,
                Description = entity.Description,
                KgReduce = entity.KgReduce,
                PercentReduce = entity.PercentReduce,
				FirstWeight = entity.FirstWeight,
				InHour = entity.InHour,
				ItemName = entity.ItemName,
				ItemNumber = entity.ItemNumber,
				ItemUnit = entity.ItemUnit,
				ItemUnit2 = entity.ItemUnit2,
				LocationCode = entity.LocationCode,
                LocationName = entity.LocationName,
                ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				OutHour = entity.OutHour,
				Quantity1 = entity.Quantity1,
				Quantity2 = entity.Quantity2,
                RequireCode = entity.RequireCode,
                RequireName = entity.RequireName,
				ScaleTicketCode = entity.ScaleTicketCode,
				ScaleTicketID = entity.ScaleTicketID,
				SecondWeight = entity.SecondWeight,
				VehicleID = entity.VehicleID,
                RateDB = entity.Rate,
                RowVersion = VersionConverter.ToString(entity.RowVersion)
			};
		}

		#endregion

		#region ToBusinessObjectHasChildren

		public static ScaleTicketDTO ToBusinessObjectHasChildren(ScaleTicket entity, params Type[] types)
		{
			if (entity == null)
			{
				return null;
			}
			ScaleTicketDTO businessobject = new ScaleTicketDTO
			{
				Active = entity.Active,
				ActualWeight = entity.ActualWeight,
				CustomerCode = entity.CustomerCode,
				CustomerName = entity.CustomerName,
                Description = entity.Description,
				FirstWeight = entity.FirstWeight,
				InHour = entity.InHour,
				ItemName = entity.ItemName,
				ItemNumber = entity.ItemNumber,
				ItemUnit = entity.ItemUnit,
				ItemUnit2 = entity.ItemUnit2,
				LocationCode = entity.LocationCode,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				OutHour = entity.OutHour,
				Quantity1 = entity.Quantity1,
				Quantity2 = entity.Quantity2,
                RequireCode = entity.RequireCode,
                RequireName = entity.RequireName,
                RequireLimit = entity.RequireLimit,
				ScaleTicketCode = entity.ScaleTicketCode,
				ScaleTicketID = entity.ScaleTicketID,
				SecondWeight = entity.SecondWeight,
				VehicleID = entity.VehicleID,
                RowVersion = VersionConverter.ToString(entity.RowVersion)
			};
			return businessobject;
		}

		#endregion

	}
}
